// 首页
// https://buy.jdxia.com/

// 登录
// https://buy.jdxia.com/#/login

// 接单
// https://buy.jdxia.com/buyer/v1/releaseTask/index



// 首页
let token = Android.getMap("token")
localStorage.setItem("Authorization", token)


// 获取tokeN
function getAndroidToken() {
    let token = localStorage.getItem("Authorization").replace(/^"|"$/g, '');
    return token
}
getAndroidToken()


// 接单
function getParameterHandler() {
    let headers = {
        "authorization": "Bearer " + parameter.getMap("token"),
        "webversion": "24081401"
    }
    let body = {}
    let strUrl = `?status=2&currentPage=1`
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "GET",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()


// 处理返回数据
function getResponse() {
    let res = response.getMap("res")
    let code = "500"
    let message = "接单中"

    res = JSON.parse(res)
    if (res["code"] == 200 && res["data"]["dataCount"] > 0) {
        code = "200"
        message = "接单成功，请尽快完成"
    } else if (res["code"] == 200 && res["data"]["dataCount"] <= 0) {
        code = "500"
        message = "接单中"
    } else {
        code = "300"
        message = res["message"]
    }

    return {
        code: code,
        message: message,
        dataKey: "",
        dataValue: ""
    }
}
getResponse()
